package creational.factory.sampleFactory;

import creational.factory.sampleFactory.products.Apple;
import creational.factory.sampleFactory.products.Grape;

public final class FruitCreator {

    public static Fruit factory(String type) throws FactoryException{
        Fruit fruit = null;
        if ("apple".equals(type)) {
            fruit = new Apple();
        } else if ("grape".equals(type)) {
            fruit = new Grape();
        } else {
            throw new FactoryException();
        }
        fruit.init();
        return fruit;
    }
}
